/*
*  Copyright 2019-2023 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.mes.rest;

import me.zhengjie.annotation.Log;
import me.zhengjie.modules.mes.domain.MesPageConfig;
import me.zhengjie.modules.mes.domain.vo.MesPageConfigVo;
import me.zhengjie.modules.mes.service.MesPageConfigService;
import me.zhengjie.modules.mes.domain.vo.MesPageConfigQueryCriteria;
import lombok.RequiredArgsConstructor;
import java.util.List;

import me.zhengjie.service.MinioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.utils.PageResult;
import org.springframework.web.multipart.MultipartFile;

/**
* @author mfc
* @date 2024-12-31
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "MesPageConfig管理")
@RequestMapping("/api/mesPageConfig")
public class MesPageConfigController {

    private final MesPageConfigService mesPageConfigService;


    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('mesPageConfig:list')")
    public void exportMesPageConfig(HttpServletResponse response, MesPageConfigQueryCriteria criteria) throws IOException {
        mesPageConfigService.download(mesPageConfigService.queryAll(criteria), response);
    }

    @GetMapping
    @Log("查询MesPageConfig")
    @ApiOperation("查询MesPageConfig")
    @PreAuthorize("@el.check('mesPageConfig:list')")
    public ResponseEntity<PageResult<MesPageConfig>> queryMesPageConfig(MesPageConfigQueryCriteria criteria, Page<Object> page){
        return new ResponseEntity<>(mesPageConfigService.queryAll(criteria,page),HttpStatus.OK);
    }

    @PostMapping
    @Log("新增MesPageConfig")
    @ApiOperation("新增MesPageConfig")
    @PreAuthorize("@el.check('mesPageConfig:add')")
    public ResponseEntity<Object> createMesPageConfig(@Validated @RequestBody MesPageConfig resources){
        mesPageConfigService.create(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }

    @PutMapping
    @Log("修改MesPageConfig")
    @ApiOperation("修改MesPageConfig")
    @PreAuthorize("@el.check('mesPageConfig:edit')")
    public ResponseEntity<Object> updateMesPageConfig(@Validated @RequestBody MesPageConfig resources){
        mesPageConfigService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @Log("删除MesPageConfig")
    @ApiOperation("删除MesPageConfig")
    @PreAuthorize("@el.check('mesPageConfig:del')")
    public ResponseEntity<Object> deleteMesPageConfig(@RequestBody List<Integer> ids) {
        mesPageConfigService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @GetMapping("/queryAllByCriterias")
    @ApiOperation("分页查询MesPageConfig")
    public ResponseEntity<PageResult<MesPageConfigVo>> queryAllByCriterias(MesPageConfigQueryCriteria criteria, Page<Object> page){
        return new ResponseEntity<>(mesPageConfigService.queryAllByCriterias(criteria,page),HttpStatus.OK);
    }
}